import { defHttp } from '@/utils/http/axios';
import { ITree, ITreeAddData, ITreeEditData, IndustrySector } from './type';
import { DataStatusEnum, OrgInitEnum } from '@/enums/publicEnum';

enum Api {
    productCategoryListApi = '/admin/activity/org/category/treeOp',
    productCategoryAddApi = '/admin/activity/org/category/add',
    productCategoryEditApi = '/admin/activity/org/category/edit',
    productCategoryDelApi = '/admin/activity/org/category/del',
    productCategorySwapApi = '/admin/activity/org/category/swap',
    productCategoryEnable = '/admin/activity/org/category/enable',

    industryListApi = '/admin/org/industry-info/category/tree',
    industryAddApi = '/admin/org/industry-info/category/add',
    industryEditApi = '/admin/org/industry-info/category/edit',
    industryDelApi = '/admin/org/industry-info/category/del',
    industrySwapApi = '/admin/org/industry-info/category/swap',
    industryEnable = '/admin/org/industry-info/category/enable'
}

/**
 * @description 产品类目列表
 * @date
 * @export
 * @param
 */
export function productCategoryList(params: any) {
    return defHttp.get<ITree[]>({
        url: Api.productCategoryListApi,
        params
    });
}

/**
 * @description 新建产品类目
 * @date 26/01/2024
 * @export
 * @param {CategorytAddData} data
 */
export function productCategoryAdd(data: ITreeAddData) {
    return defHttp.post({ url: Api.productCategoryAddApi, data });
}

/**
 * @description 编辑产品类目
 * @date 26/01/2024
 * @export
 * @param {ProducCategorytEditData} data
 */
export function productCategoryEdit(data: ITreeEditData) {
    return defHttp.post({ url: Api.productCategoryEditApi, data });
}

/**
 * @description 删除产品类目
 * @date 26/01/2024
 * @export
 * @param {number} id
 */
export function productCategoryDel(id: number) {
    return defHttp.post({ url: Api.productCategoryDelApi + `/${id}` });
}

/**
 * @description 产品类目切换排序
 * @date 26/01/2024
 * @export
 * @param {number[]} data
 */
export function productCategorySwap(data: number[]) {
    return defHttp.post({ url: Api.productCategorySwapApi, data });
}


/**
 * 禁用启用分类
 * @param data 
 * @returns 
 */
export function productCategoryEnable(data: { id: number, status: DataStatusEnum }) {
    return defHttp.post({ url: `${Api.productCategoryEnable}`,data });
}


/**
 * @description 行业分类列表
 * @date
 * @export
 * @param
 */
export function industryList(params: any) {
    return defHttp.get<IndustrySector[]>({
        url: Api.industryListApi,
        params
    });
}

/**
 * @description 新建行业分类
 * @date 26/01/2024
 * @export
 * @param {CategorytAddData} data
 */
export function industryAdd(data: ITreeAddData) {
    return defHttp.post({ url: Api.industryAddApi, data });
}

/**
 * @description 编辑行业分类
 * @date 26/01/2024
 * @export
 * @param {CategorytEditData} data
 */
export function industryEdit(data: ITreeEditData) {
    return defHttp.post({ url: Api.industryEditApi, data });
}

/**
 * @description 删除行业分类
 * @date 26/01/2024
 * @export
 * @param {number} id
 */
export function industryDel(id: number) {
    return defHttp.post({ url: Api.industryDelApi + `/${id}` });
}

/**
 * @description 行业分类切换排序
 * @date 26/01/2024
 * @export
 * @param {number[]} data
 */
export function industrySwap(data: number[]) {
    return defHttp.post({ url: Api.industrySwapApi, data });
}

/**
 * 禁用启用行业分类
 * @param data 
 * @returns 
 */
export function industryEnable(data: { id: number, status?: DataStatusEnum, orgInit?: OrgInitEnum }) {
    return defHttp.post({ url: `${Api.industryEnable}`, data });
}